package org.dcc.controller.registrar;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;
import java.util.Set;

public class MyRegistrar implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

        BeanDefinition beanDefinition = new GenericBeanDefinition();
        Set<String> set = importingClassMetadata.getAnnotationTypes();
        importingClassMetadata.getMetaAnnotationTypes(EnableHelloService.class.getName());
        Map<String, Object> map = importingClassMetadata.getAnnotationAttributes(EnableHelloService.class.getName());
        String value = (String)map.get("value");

        beanDefinition.setBeanClassName(value);
        registry.registerBeanDefinition("helloService", beanDefinition);




    }
}
